/**
 * Mocking client-server processing
 */
const _products = [
  {
    id:1,
    src:'img/apple/1.jpg',
    title:'美国华盛顿甜脆红地厘蛇果',
    desc: '经典红果 甜脆出众 送礼佳品 ',
    price:'128.00',
    isSelected: true,
    inventory:'8',
    style: {
      '4个（尝鲜装）': 'img/apple/1.jpg',
      '8个（悦享装）': 'img/apple/2.jpg',
      '18个（礼品装）': 'img/apple/3.jpg',
      '20个（尊享装）': 'img/apple/4.jpg',
    },
    activeStyleUrl: 'https://imgqn2.fruitday.com/images/product_pic/52/1/1-370x370-52-HF73PYWP.jpg',
    storage: {
      '4个（尝鲜装）': 5288,
      '8个（悦享装）': 6088,
      '18个（礼品装）': 6888,
      '20个（尊享装）':82.90
    }
  },

  {
    id: 2,
    title: "iPad 4 Mini",
    src:'img/apple/1.jpg',
    desc: '3D Touch、1200万像素照片、4k视频，强大功能于一身。',
    price: 2800.00,
    inventory: 2,
    isSelected: true,
    style: {
      '银色': 'http://o8yu724qs.bkt.clouddn.com/iphone6s-silver-select-2015.png',
      '深空灰色': 'http://o8yu724qs.bkt.clouddn.com/iphone6s-gray-select-2015.png',
      '金色': 'http://o8yu724qs.bkt.clouddn.com/iphone6s-gold-select-2015.png',
      '玫瑰金色': 'http://o8yu724qs.bkt.clouddn.com/iphone6s-rosegold-select-2015.png'
    },
    activeStyleUrl: 'http://o8yu724qs.bkt.clouddn.com/iphone6s-silver-select-2015.png',
    storage: {
      '16GB': 5288,
      '64GB': 6088,
      '128GB': 6888
    }
  },
  {
    id:3,
    src:'img/apple/1.jpg',
    title:'美国华盛顿甜脆红地厘蛇果',
    price:'1299.00',
    shopsSrc:'../../../static/images/JDmyself.png',
    description:'双镜头，大内存，长续航！畅玩6X,4GB+32GB,全网通4G,高配版,铂光金!',
    inventory:'8',
  },
  {
    id:4,
    src:'img/apple/1.jpg',
    title:'美国华盛顿甜脆红地厘蛇果',
    price:'1299.00',
    shopsSrc:'../../../static/images/JDmyself.png',
    description:'双镜头，大内存，长续航！畅玩6X,4GB+32GB,全网通4G,高配版,铂光金!',
    inventory:'8',
  },
  {
    id:1,
    src:'img/apple/1.jpg',
    title:'美国华盛顿甜脆红地厘蛇果',
    price:'1299.00',
    description:'双镜头，大内存，长续航！畅玩6X,4GB+32GB,全网通4G,高配版,铂光金!',
    inventory:'8',
  }
  // {id: 2, title: "H&M T-Shirt White", price: 3999.00, inventory: 10},
  // {id: 3, title: "Charli XCX - Sucker CD", price: 999.00, inventory: 5}
]

export default {
  getProducts (cb) {
    setTimeout(() => cb(_products), 100)
  },

  buyProducts (products, cb, errorCb) {
    setTimeout(() => {
      // simulate random checkout failure.
      (Math.random() > 0.5 || navigator.userAgent.indexOf('PhantomJS') > -1)
        ? cb()
        : errorCb()
    }, 100)
  }
}
